package com.example.controller.admin;


import com.example.pojo.Pattern;
import com.example.pojo.User;
import com.example.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;


@RequestMapping("/admin/user")
@RestController
@Slf4j
public class UserController {

    @Resource
    private UserService userService;

    @Resource
    private Pattern pattern;

    // @Value("${pattern.dataformat}")
    // private String dataFormat;

    /**
     * 删除分类
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public User getOrder(@PathVariable Long id){
       return userService.getUserById(id);
    }


    @GetMapping("now")
    public String now(){
        // return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dataFormat));
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(pattern.getDateformat()));
    }

}
